package com.quectel.aiot.mapper;

import com.quectel.aiot.entity.Product;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ProductMapper {
    
    @Insert("INSERT INTO product (product_key, product_name, product_desc, create_time, update_time, " +
            "project_id, auth_type, custom_fields, net_type, node_type, status) " +
            "VALUES (#{productKey}, #{productName}, #{productDesc}, #{createTime}, #{updateTime}, " +
            "#{projectId}, #{authType}, #{customFields}, #{netType}, #{nodeType}, #{status})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(Product product);

    @Select("SELECT * FROM product WHERE product_key = #{productKey}")
    Product findByProductKey(String productKey);

    @Update("UPDATE product SET product_name = #{productName}, product_desc = #{productDesc}, " +
            "update_time = #{updateTime}, project_id = #{projectId}, auth_type = #{authType}, " +
            "custom_fields = #{customFields}, net_type = #{netType}, node_type = #{nodeType}, " +
            "status = #{status} WHERE product_key = #{productKey}")
    int update(Product product);

    @Select("SELECT * FROM product")
    List<Product> findAll();
} 